package com.peng;

import java.util.LinkedList;
import java.util.List;

public class ColliderChain implements Collider {

    private List<Collider> colliderList = new LinkedList<>();

    public ColliderChain() {
        add(new TankBulletCollider());
        add(new TankTankCollider());
        add(new BulletWallCollider());
        add(new TankWallCollider());
    }

    public void add(Collider collider) {
        colliderList.add(collider);
    }

    @Override
    public boolean collide(GameObject g1, GameObject g2) {
        for (Collider collider : colliderList) {
            if (collider.collide(g1, g2)) {
                return true;
            }
        }
        return false;
    }
}
